<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Object model &mdash; Dragonfly v0.6.4rc3 documentation</title>
    <link rel="stylesheet" href="_static/default.css" type="text/css" />
    <link rel="stylesheet" href="_static/pygments.css" type="text/css" />
    <script type="text/javascript">
      var DOCUMENTATION_OPTIONS = {
          URL_ROOT:    '',
          VERSION:     '0.6.4rc3',
          COLLAPSE_MODINDEX: false,
          FILE_SUFFIX: '.html'
      };
    </script>
    <script type="text/javascript" src="_static/jquery.js"></script>
    <script type="text/javascript" src="_static/doctools.js"></script>
    <link rel="contents" title="Global table of contents" href="contents.html" />
    <link rel="index" title="Global index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="top" title="Dragonfly v0.6.4rc3 documentation" href="index.html" />
    <link rel="up" title="Introduction" href="introduction.html" />
    <link rel="next" title="Grammar sub-package" href="grammar.html" />
    <link rel="prev" title="Installation" href="installation.html" />
  </head>
  <body>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="grammar.html" title="Grammar sub-package"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installation"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Dragonfly v0.6.4rc3 documentation</a> &raquo;</li>
          <li><a href="introduction.html" accesskey="U">Introduction</a> &raquo;</li>
      </ul>
    </div>
    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body">
            
  
  <div class="section" id="object-model">
<h1>Object model<a class="headerlink" href="#object-model" title="Permalink to this headline">¶</a></h1>
<p>The core of Dragonfly is a language object model revolving
around three types: grammars, rules, and elements.  This section
describes that object model.</p>
<div class="section" id="grammars">
<h2>Grammars<a class="headerlink" href="#grammars" title="Permalink to this headline">¶</a></h2>
<p>A grammar is a collection of rules.  It manages the rules,
loading and unloading them, activating and deactivating them,
and taking care of all communications with the speech
recognition engine.  When they recognition occurs, the
associated grammar received the recognition event and dispatches
it to the appropriate rule.</p>
<p>Normally a grammar is associated with a particular context or
functionality.  Normally the rules within a grammar are somehow
related to each other.  However, neither of these is strictly
necessary, they are just common use patterns.</p>
<p>The <tt class="docutils literal"><span class="pre">Grammar</span></tt> class and derived classes are described
in section <a class="reference external" href="grammarclasses.html#refgrammarclasses"><em>Grammar classes reference</em></a>.</p>
</div>
<div class="section" id="rules">
<h2>Rules<a class="headerlink" href="#rules" title="Permalink to this headline">¶</a></h2>
<p>A rule represents a voice command or part of one.  Its elements
define exactly what its contents are, i.e. what can be said to
activate this rule.  It has several attributes which determine,
for example, whether it is a top-level &#8220;standalone&#8221; command
which can be spoken directly, or whether it can only be
referenced from a different top level rule.</p>
<p>Each rule has one root element which defines the language
content of the rule.  Top-level rules have callback methods
which are called when the rule is recognized.</p>
</div>
<div class="section" id="elements">
<h2>Elements<a class="headerlink" href="#elements" title="Permalink to this headline">¶</a></h2>
<p>Elements are the basic building blocks of the language model.
The define exactly what can be said, inform the content of
rules.  The most common elements are:</p>
<blockquote>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">Literal(...)</span></tt> &#8211; one or more literal words.</li>
<li><tt class="docutils literal"><span class="pre">Sequence(...)</span></tt> &#8211; a series of other elements.</li>
<li><tt class="docutils literal"><span class="pre">Alternative(...)</span></tt> &#8211; a choice of other elements, only
one of which can be said within a single recognition.</li>
<li><tt class="docutils literal"><span class="pre">Optional(...)</span></tt> &#8211; an element container which makes
its single child element optional.</li>
<li><tt class="docutils literal"><span class="pre">RuleRef(...)</span></tt> &#8211; a reference to another rule.</li>
<li><tt class="docutils literal"><span class="pre">ListRef(...)</span></tt> &#8211; a reference to a list, which is
a dynamic language element which can be updated and
modified without reloading the grammar.</li>
<li><tt class="docutils literal"><span class="pre">Dictation(...)</span></tt> &#8211; a free-form dictation element
which allows the speaker to say one or more natural
language words.</li>
</ul>
</blockquote>
<p>The above mentioned element types are at the heart of
Dragonfly&#8217;s object model.  But of course using them all the time
to specify every grammar would be quite tedious.  There is
therefore also a special element which constructs these basic
element types from a string specification:</p>
<blockquote>
<ul class="simple">
<li><tt class="docutils literal"><span class="pre">Compound(...)</span></tt> &#8211; a special element which parses a string
spec to create a hierarchy of basic elements.  The format of
this spec is described <a class="reference external" href="compound.html#refcompound"><em>Compound elements reference</em></a>.</li>
</ul>
</blockquote>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar">
        <div class="sphinxsidebarwrapper">
            <h3>Table Of Contents</h3>
            <ul>
<li><a class="reference external" href="">Object model</a><ul>
<li><a class="reference external" href="#grammars">Grammars</a></li>
<li><a class="reference external" href="#rules">Rules</a></li>
<li><a class="reference external" href="#elements">Elements</a></li>
</ul>
</li>
</ul>

            <h4>Previous topic</h4>
            <p class="topless"><a href="installation.html" title="previous chapter">Installation</a></p>
            <h4>Next topic</h4>
            <p class="topless"><a href="grammar.html" title="next chapter">Grammar sub-package</a></p>
            <h3>This Page</h3>
            <ul class="this-page-menu">
              <li><a href="_sources/objectmodel.txt">Show Source</a></li>
            </ul>
            <h3>Quick search</h3>
            <form class="search" action="search.html" method="get">
              <input type="text" name="q" size="18" /> <input type="submit" value="Go" />
              <input type="hidden" name="check_keywords" value="yes" />
              <input type="hidden" name="area" value="default" />
            </form>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="modindex.html" title="Global Module Index"
             accesskey="M">modules</a> |</li>
        <li class="right" >
          <a href="grammar.html" title="Grammar sub-package"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="installation.html" title="Installation"
             accesskey="P">previous</a> |</li>
        <li><a href="index.html">Dragonfly v0.6.4rc3 documentation</a> &raquo;</li>
          <li><a href="introduction.html" accesskey="U">Introduction</a> &raquo;</li>
      </ul>
    </div>
    <div class="footer">
      &copy; Copyright 2008, Christo Butcher.
      Last updated on Feb 01, 2009.
      Created using <a href="http://sphinx.pocoo.org/">Sphinx</a>.
    </div>
  </body>
</html>